<%@page import="java.math.RoundingMode"%>
<%@page import="java.math.BigDecimal"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html class=""><head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>NutriWeb - Praticando alimentação saudável</title>

        <meta class="viewport" name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <!-- Favicon -->
        <link rel="shortcut icon" href="a_data/icone_nutriweb.ico">
        <!-- Font -->
        <link rel="stylesheet" href="arquivos_arquivos/css.css">
        <!-- Plagins CSS -->
        <link rel="stylesheet" href="arquivos_arquivos/buttons.css">
        <link rel="stylesheet" href="arquivos_arquivos/social-icons.css">
        <link rel="stylesheet" href="arquivos_arquivos/font-awesome.css">
        <link rel="stylesheet" href="arquivos_arquivos/bootstrap.css">
        <link rel="stylesheet" href="arquivos_arquivos/jslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/settings.css">
        <link rel="stylesheet" href="arquivos_arquivos/jquery.css">
        <link rel="stylesheet" href="arquivos_arquivos/animate.css">
        <link rel="stylesheet" href="arquivos_arquivos/video-js.css">
        <link rel="stylesheet" href="arquivos_arquivos/morris.css">
        <link rel="stylesheet" href="arquivos_arquivos/royalslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/rs-minimal-white.css">
        <link rel="stylesheet" href="arquivos_arquivos/layerslider.css">
        <link rel="stylesheet" href="arquivos_arquivos/ladda.css">
        <link rel="stylesheet" href="arquivos_arquivos/datepicker.css">
        <link rel="stylesheet" href="arquivos_arquivos/jquery_002.css">
        <!-- Theme CSS -->
        <link rel="stylesheet" href="a_data/style.css">
        <!-- Responsive CSS -->
        <link rel="stylesheet" href="a_data/responsive.css">
        <!-- Custom CSS -->
        <link rel="stylesheet" href="a_data/pages.css">
        <link rel="stylesheet" href="a_data/home-pages-customizer.css">
        <!-- IE Styles-->
        <link rel="stylesheet" href="a_data/ie.css">
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
              <link rel='stylesheet' href="css/ie/ie8.css">
        <![endif]-->
        <style type="text/css">
            .jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}</style>
        <style type="text/css">.fancybox-margin{margin-right:19px;}</style>
        <script style="" src="arquivos_arquivos/commonutilstats.js" charset="UTF-8" type="text/javascript"></script>
    </head>
    <body class="fixed-header loaded fixed">
        <div class="page-box">
            <div class="page-box-content">

                <%@include file="/templates/header.jsp"%>   
                <%
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                    if (request.getParameter("slQtde") != null) {

                        Integer quantidade = Integer.parseInt(request.getParameter("slQtde").toString());
                        java.sql.Timestamp data = new java.sql.Timestamp(new Date().getTime());

                        Object[] params = new Object[]{quantidade, data, Long.parseLong(session.getAttribute("cd_usuario").toString())};

                        SQL = "INSERT INTO \"Operacoes\".\"HIDRATACAO\" (qt_hidratacao, dt_hidratacao, cd_usuario) "
                                + "VALUES (?,?,?)";
                        try {
                            Conexao.executeStatement(SQL, params);
                            response.sendRedirect(request.getContextPath() + "/beber.jsp");
                            return;
                        } catch (Exception e) {
                            out.println("Atenção, erro ao inserir " + e.getLocalizedMessage());
                        }
                    }

                    if (request.getParameter("delete") != null) {
                        Long cd = Long.parseLong(request.getParameter("delete"));

                        Object[] params = new Object[]{cd};

                        SQL = "DELETE FROM \"Operacoes\".\"HIDRATACAO\" WHERE cd_hidratacao = ? ";
                        try {
                            Conexao.executeStatement(SQL, params);
                            response.sendRedirect(request.getContextPath() + "/beber.jsp");
                            return;
                        } catch (Exception e) {
                            out.println("Atenção, erro ao deletar " + e.getLocalizedMessage());
                        }
                    }%>
                <div class="breadcrumb-box">
                    <div class="container">
                        <ul class="breadcrumb">
                            <li><a href="inicio.jsp">Início</a> </li>
                            <li class="active">Hidratação</li>
                        </ul>	
                    </div>
                </div>
                <%@include file="/templates/welcome.jsp"%>
                <div class="clearfix"></div>

                <section id="main">
                    <header class="page-header">
                        <div class="container">
                            <h1 class="title">Hidratação</h1>
                        </div>	
                    </header>

                    <div class="container">
                        <div class="panel-group" id="accordion3">

                            <div class="col-sm-6 col-md-8 bottom-padding">

               <div class="content-block bottom-padding frame-shadow-lifted bg">

    <p align="justify"> &nbsp;&nbsp;Use água tratada ou fervida e filtrada, para beber e
para preparar refeições e sucos ou outras bebidas.<br/>&nbsp;&nbsp;&nbsp;
Beba pelo menos de dois litros (seis a oito copos) de
água por dia. Dê preferência ao consumo de água
nos intervalos das refeições.&nbsp;
 Ofereça água para crianças e idosos ao longo de
todo o dia. Eles precisam ser estimulados
ativamente a ingerir água. </p>
    

</div> 
                                <!--descrição do aimentoem texto-->
                                <table class="table table-striped text-left order-details ">
                                    <thead>
                                        <tr>
                                            <th class="product-name">Quantidade</th>
                                            <th class="product-total">Hora</th>
                                            <th class="product-total">&nbsp;</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <%
                                            SimpleDateFormat hmf = new SimpleDateFormat("HH:mm");

                                            Integer total = 0;
                                            Integer diaria = 2000;
                                            Integer percent = 0;
                                            String strTotal = "";

                                            SQL = "SELECT qt_hidratacao, dt_hidratacao, cd_hidratacao "
                                                    + "FROM \"Operacoes\".\"HIDRATACAO\" "
                                                    + " WHERE date(dt_hidratacao) = '" + new java.sql.Date(df.parse(df.format(new Date().getTime())).getTime()) + "' "
                                                    + " AND cd_usuario = " + Long.parseLong(session.getAttribute("cd_usuario").toString()) + " "
                                                    + " ORDER BY dt_hidratacao ";
                                            try {
                                                for (Object[] reg : Conexao.getQuery(SQL)) {
                                        %>                                       
                                        <tr>
                                            <td class="product-name"><% out.print((reg[0].toString().equals("1000") ? "1L" : reg[0].toString() + "ml")); %></td>
                                            <td class="product-name"><% out.print(hmf.format(odtf.parse(reg[1].toString())) + "hs");%></td>
                                            <td class="product-name"><!--botao excluir-->  
                                                <a class="btn btn-warning btn-xs" href="<%=request.getContextPath()%>/beber.jsp?delete=<% out.print(reg[2].toString()); %>" name="btnExcluirCRT"> 
                                                    <i > <svg id="canvas-for-livicon-57" height="16" version="1.1" width="16" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative; left: -0.100006px; top: 0.883301px;">
                                                        <desc> … </desc>
                                                        <defs></defs>
                                                        <path style="opacity: 0;" fill="#ffffff" stroke="none" d="M36.495,5.671L34.205,6.571000000000001C34.205,6.571000000000001,33.299,7.331,32.951,7.1240000000000006C32.571,6.898000000000001,32.864,5.6240000000000006,32.864,5.6240000000000006L33.598,4.686000000000001L32,2.812L34.031,1.8739999999999999C34.031,1.8739999999999999,34.83,0.46899999999999986,35.025,0.46899999999999986C35.458,0.46899999999999986,37.185,1.8739999999999999,37.185,1.8739999999999999L36.193000000000005,0.7959999999999998L37.186,0L40.211,0.936C40.211,0.936,39.348,2.343,39.778999999999996,2.812S40.601,7.125,40.169999999999995,7.125C39.736,7.125,36.928,4.077999999999999,36.928,4.077999999999999L40.04,7.498999999999999L38.396,7.325999999999999L36.71,8.155L33.814,7.263999999999999L36.495,5.671Z" opacity="0" stroke-width="0" transform="matrix(0.5,0,0,0.5,0,0)"></path>
                                                        <path style="" fill="#ffffff" stroke="none" d="M24.801,8.1H20V4.7C20,4.369,19.73,4.1000000000000005,19.4,4.1000000000000005H10.6C10.269,4.1000000000000005,10,4.369000000000001,10,4.7V8.1H5.2C4.537,8.1,4,8.637,4,9.3V11H26V9.3C26,8.637,25.463,8.1,24.801,8.1ZM12,8.1V6.1H18V8.1H12Z" transform="matrix(0.5,0,0,0.5,0,0)" stroke-width="0"></path>
                                                        <path style="" fill="#ffffff" stroke="none" d="M8.4,30H21.6C22.926000000000002,30,24,28.926,24,27.6V12H6V27.6C6,28.926,7.075,30,8.4,30ZM10,26H8V14H10V26ZM14,26H12V14H14V26ZM18,26H16V14H18V26ZM22,26H20V14H22V26Z" stroke-width="0" transform="matrix(0.5,0,0,0.5,0,0)"></path>
                                                        </svg> </i> </a></td>
                                        </tr>
                                        <%
                                                total = total + Integer.parseInt(reg[0].toString());
                                            }
                                            percent = (int) Math.round(((total * 100) / diaria));
                                            if (total < 1000) {
                                                strTotal = String.valueOf(total) + "ml";
                                            } else {
                                                strTotal = String.valueOf(new BigDecimal(String.valueOf((double) total / 1000)).setScale(2, RoundingMode.HALF_UP).stripTrailingZeros()) + "L";
                                            }
                                        %> 
                                    <thead>
                                        <tr>
                                            <th class="product-name" colspan="3">
                                    <p><% out.print(strTotal);%> de 2L</p><div class="progress progress-striped active border-radius hover">
                                        <div class="progress-bar progress-bar-info" style="width:<% out.print(percent);%>%;"> <% out.print(percent);%>% </div>
                                    </div>

                                    </tr>
                                    </thead>
                                    <%  } catch (Exception e) {
                                            out.println("Atenção, " + e.getLocalizedMessage());
                                        }
                                    %>  
                                    </tbody>

                                </table>
                            </div>
                            <span></span>      

                            <div class="col-sm-6 col-md-4 bottom-padding">
                                <form id="contactform" action="" novalidate="novalidate" class="form-box register-form form-validator bv-form" method="post">
                                    <h3 class="title">Beber Água </h3>
                                    <div id="success"></div>

                                    <label>Quantidade: <span class="required">*</span></label>
                                    <select class="form-control" data-bv-emailaddress-message="Selecione um alimento"
                                            required name="slQtde" class="form-control" >
                                        <option value="" name="selCereal"  selected>Selecione uma quantidade...</option>
                                        <option value="10">10ml</option>
                                        <option value="20">20ml</option>
                                        <option value="50">50ml</option>
                                        <option value="100">100ml</option>
                                        <option value="200">200ml</option>
                                        <option value="500">500ml</option>
                                        <option value="1000">1L</option>
                                    </select>
                                    <div class="buttons-box clearfix">
                                        <button type="submit" class="btn btn-default">Beber</button>
                                        <span class="required"><b>*</b> Campo Obrigatório	</span>
                                    </div><!-- .buttons-box -->
                                </form>


                            </div>


                        </div>


                    </div>
                </section><!-- #main -->

            </div><!-- .page-box-content -->
        </div><!-- .page-box -->

        <%@include file="/templates/footer.jsp"%> 
        <div class="clearfix"></div>

        <script async="" src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/www-widgetapi.js" id="www-widgetapi-script"></script><script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/iframe_api"></script><script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_015.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrap.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jshashtable-2.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_018.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/tmpl.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_012.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/draggable-0.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_021.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_016.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_022.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_009.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_019.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_011.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_007.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_008.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_005.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/isotope.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_006.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_017.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_020.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_003.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_013.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/SmoothScroll.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/country.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/spin.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/ladda.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/masonry.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/morris.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/raphael.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/video.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/pixastic.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/livicons-1.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/greensock.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/layerslider_002.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/layerslider.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_014.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_004.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrapValidator.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/bootstrap-datepicker.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_010.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jplayer.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/jquery_002.js"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/main.js"></script>


        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/js" type="text/javascript"></script>
        <script src="Accordions%20&amp;%20Toggles%20_%20Progressive%20%E2%80%94%20Responsive%20Multipurpose%20HTML%20Template_arquivos/main_002.js"></script>
    </body>
</html>
